using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class MainPanle : BasePanel
{
    [SerializeField] private PlayerData playerData;
    [SerializeField] private Button startGame;

    [SerializeField] private Button loadData;

    [SerializeField] private Button settingGame;

    [SerializeField] private Button explainPanel;

    [SerializeField] private Button exitGame;
    
    
    // 
    private void Start()
    {
        startGame.onClick.AddListener(StartGame);
        loadData.onClick.AddListener(LoadData);
        settingGame.onClick.AddListener(SettingGame);
        explainPanel.onClick.AddListener(ExplainPanel);
        exitGame.onClick.AddListener(ExitGame);
    }

    // 
    private void Update()
    {
        
    }
    
    //
    private void StartGame()
    {
        //
        UIManager.Instance.OpenPanel(UIConst.PANEL_CREATE);
        // 获取输入的 用户名
        // playerData.playerName = "PlayerSaveData";
        // // 血量最大值，分数为零
        // playerData.playerBlood = playerData.GetPlayerBloodMax;
        // playerData.playerScore = 0;
        // // 第一关，教学关卡
        // playerData.sceneIndex = 1;
        // // 加载场景
        // EventCenter.Instance.EventTrigger(EventName.EVENT_SCENE_SCENESWITE, playerData.sceneIndex);
        // // 创建存档
        // SaveDataSystem.SaveByJson(playerData.playerName, playerData);
        // // 关闭 页面
        // UIManager.Instance.ClosePanel(UIConst.PANEL_CREATE);
    }
    
    //
    private void LoadData()
    {
        //
        UIManager.Instance.OpenPanel(UIConst.PANEL_LOAD);
        // PlayerData playerData = SaveDataSystem.LoadFromJson<PlayerData>("PlayerSaveData");
        // if (playerData == null)
        // {
        //     print("存档PlayerSaveData是空的");
        //     return;
        // }
        // this.playerData.playerBlood = playerData.playerBlood;
        // this.playerData.playerScore = playerData.playerScore;
        // this.playerData.playerPosition = playerData.playerPosition;
        // this.playerData.sceneIndex = playerData.sceneIndex;
        //
        // // 加载存档场景
        // EventCenter.Instance.EventTrigger(EventName.EVENT_SCENE_SCENESWITE, this.playerData.sceneIndex);
    }
    
    //
    private void SettingGame()
    {
        //
        UIManager.Instance.OpenPanel(UIConst.PANEL_SETTING);
    }
    
    //
    private void ExplainPanel()
    {
        //
        UIManager.Instance.OpenPanel(UIConst.PANEL_EXPLAIN);
    }
    
    //
    private void ExitGame()
    {
        // 
    }
}
